package com.ruoyi.web.controller.datas;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.hust.domain.QualityMonitor;
import com.hust.service.IQualityMonitorService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水质月监测数据Controller
 * 
 * @author hust
 * @date 2024-12-13
 */
@RestController
@RequestMapping("/datas/waterquality")
public class QualityMonitorController extends BaseController
{
    @Resource
    private IQualityMonitorService qualityMonitorService;

    /**
     * 查询水质月监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:list')")
    @GetMapping("/list")
    public TableDataInfo list(QualityMonitor qualityMonitor)
    {
        startPage();
        List<QualityMonitor> list = qualityMonitorService.selectQualityMonitorList(qualityMonitor);
        return getDataTable(list);
    }

    /**
     * 导出水质月监测数据列表
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:export')")
    @Log(title = "水质月监测数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QualityMonitor qualityMonitor)
    {
        List<QualityMonitor> list = qualityMonitorService.selectQualityMonitorList(qualityMonitor);
        ExcelUtil<QualityMonitor> util = new ExcelUtil<QualityMonitor>(QualityMonitor.class);
        util.exportExcel(response, list, "水质月监测数据数据");
    }

    /**
     * 获取水质月监测数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:query')")
    @GetMapping(value = "/{ID}")
    public AjaxResult getInfo(@PathVariable("ID") Long ID)
    {
        return success(qualityMonitorService.selectQualityMonitorByID(ID));
    }

    /**
     * 新增水质月监测数据
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:add')")
    @Log(title = "水质月监测数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QualityMonitor qualityMonitor)
    {
        return toAjax(qualityMonitorService.insertQualityMonitor(qualityMonitor));
    }

    /**
     * 修改水质月监测数据
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:edit')")
    @Log(title = "水质月监测数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QualityMonitor qualityMonitor)
    {
        return toAjax(qualityMonitorService.updateQualityMonitor(qualityMonitor));
    }

    /**
     * 删除水质月监测数据
     */
    @PreAuthorize("@ss.hasPermi('datas:waterquality:remove')")
    @Log(title = "水质月监测数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{IDs}")
    public AjaxResult remove(@PathVariable Long[] IDs)
    {
        return toAjax(qualityMonitorService.deleteQualityMonitorByIDs(IDs));
    }
}
